﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace THO7_Team8.Dialogs
{
    public partial class BatchDialog : Form
    {
        private List<VisionAlgorithm> _algoritmeList;
        public List<VisionAlgorithm> toDoList;
        public BatchDialog(List<VisionAlgorithm> algoritmeList)
        {
            InitializeComponent();

            _algoritmeList = algoritmeList;

            foreach (VisionAlgorithm vA in algoritmeList)
            {
                listBox1.Items.Add(vA.Name);
            }

        }

        public VisionAlgorithm getVisionAlgorithmByName(String s)
        {
            foreach (VisionAlgorithm va in _algoritmeList)
            {
                if (va.Name == s)
                {
                    return va;
                }
            }
            throw new NotImplementedException();
        }

        private void addItemToListBox2()
        {
            if(listBox1.SelectedItem != null)
            {
                listBox2.Items.Add(listBox1.SelectedItem);
            }

        }
        private void removeItemFromListBox2()
        {
            listBox2.Items.Remove(listBox2.SelectedItem);
        }
        

        private void button2_Click(object sender, EventArgs e)//add
        {
            addItemToListBox2();
        }

        private void button3_Click(object sender, EventArgs e)//remove
        {
            removeItemFromListBox2();
        }
        /////////////////////////////////////////////////////////////////////////
        private void button1_Click(object sender, EventArgs e)//start
        {
            if (listBox2.Items != null)
            {
                foreach (String s in listBox2.Items)
                {
                    toDoList.Add(getVisionAlgorithmByName(s));
                }
                foreach (VisionAlgorithm va in toDoList)
                {

                }
                
            }
        }
        ////////////////////////////////////////////////////////////////////////


        private void listBox1_MouseDoubleClick(object sender, MouseEventArgs e)
        {
            addItemToListBox2();
        }

        private void listBox2_MouseDoubleClick(object sender, MouseEventArgs e)
        {
            removeItemFromListBox2();
        }

        

    }
}
